package com.ztercelstudio.demo003

import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.ztercelstudio.demo003.ui.theme.Demo003Theme

fun test(name: String = "zTercel", age: Int = 21, action: (String, Int) -> Unit) {
    action(name, age)
}

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContent {
            Demo003Theme {
                Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
                    Greeting(
                        name = "Android",
                        modifier = Modifier.padding(innerPadding)
                    )
                }
            }
        }

        sampleEntry();

        if (true) return

        test(name = "YiGuigen", age = 22, { name, age ->
            Log.d("Demo003", "print1: name $name  age $age")
        })

        test {name, age ->
            Log.d("Demo003", "print2: name $name  age $age")
        }

        test(name="YiGuiGen") {name, age ->
            Log.d("Demo003", "print3: name $name  age $age")
        }

        test(age=12) {name, age ->
            Log.d("Demo003", "print4: name $name  age $age")
        }

        val action: (String, Int) -> Unit = { name, age ->
            Log.d("Demo003", "print5: name $name  age $age")
        }

        test(action = action)


    }
}

@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
    Text(
        text = "Hello $name!",
        modifier = modifier
    )
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
    Demo003Theme {
        Greeting("Android")
    }
}